from flask import Flask, request
from fanspid import read_temperature
app = Flask(__name__)


@app.route("/init")
def init():
    return ''


@app.route("/tmp")
def hello_world():
    return {
        "tmp": read_temperature()
    }


@app.route('/pid', methods=['POST', 'GET'])
def pid():
    if request.method == 'GET':
        return {
            "p": 1,
            "i": 2,
            "d": 3
        }
    else:
        return {
            "p": 3,
            "i": 4,
            "d": 5
        }


@app.route('/fan', methods=['GET'])
def fan():
    return {
        "fan": 50
    }
